home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / ScreenSavers / SpaceSaver / Source / UserPath.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  2.7 KB  |  71 lines

  1. /* 
  2.  * UserPath.h by Bruce Blumberg, NeXT Computer, Inc.
  3.  *
  4.  * You may freely copy, distribute and re-use the code in this example.
  5.  * NeXT disclaims any warranty of any kind, expressed or implied, as
  6.  * to its fitness for any particular purpose
  7.  *
  8.  * This file and its associated .m file define a data structure and set of
  9.  * functions aimed at facilitating the use of user paths. Here is a simple
  10.  * example:
  11.  *
  12.  * UserPath *arect;
  13.  * arect = newUserPath(); // creates an empty user path
  14.  * beginUserPath(arect,YES); // initialize user path and cache
  15.  *   UPmoveto(arect,0.0,0.0); // add moveto to userpath; update bounding box
  16.  *   UPrlineto(arect,0.0,100.0); // add rlineto to path; update bounding box
  17.  *   UPrlineto(arect,100.0,0.0); // add rlineto to path; update bounding box
  18.  *   UPrlineto(arect,0.0,-100.0); // add rlineto to path; update bounding box
  19.  *   closePath(arect); // close path
  20.  * endUserPath(arect,dps_stroke); // close user path and specify operator
  21.  * sendUserPath(arect);
  22.  *
  23.  * As you will note, the set of routines manage the allocation and growth of
  24.  * the operator and operand arrays, as well as the calculation of the bounding
  25.  * box. A user path created via these functions may be optionally cached down
  26.  * at the window server, or repeatedly sent down.  The user paths created by
  27.  * this set of functions are all allocated in a unique zone.
  28.  *
  29.  * Note: the associated file is a .m file because it pulls in some .h files
  30.  * which reference objective C methods. 
  31.  */
  32.  
  33. #import <objc/objc.h>
  34. #import <dpsclient/dpsclient.h>
  35.  
  36. typedef struct _UP {
  37.     float *points;
  38.     int numberOfPoints;
  39.     char *ops;
  40.     NXPoint cp;
  41.     int numberOfOps;
  42.     int max;
  43.     float bbox[4];
  44.     int opForUserPath;
  45.     BOOL ping;
  46. } UserPath;
  47.  
  48. /* UserPath functions */
  49.  
  50. NXZone *userPathZone();
  51. UserPath *newUserPath();
  52. void freeUserPath(UserPath *up);
  53. void growUserPath(UserPath *up);
  54. void beginUserPath(UserPath *up, BOOL cache);
  55. void endUserPath(UserPath *up, int op);
  56. int sendUserPath(UserPath *up);
  57. void checkBoundingBox(UserPath *up, float x, float y);
  58. void addPts(UserPath *up, float x, float y);
  59. void addOp(UserPath *up, int op);
  60. void add(UserPath *up, int op, float x, float y);
  61. void UPmoveto(UserPath *up, float x, float y);
  62. void UPrmoveto(UserPath *up, float x, float y);
  63. void UPlineto(UserPath *up, float x, float y);
  64. void UPrlineto(UserPath *up, float x, float y);
  65. void UPcurveto(UserPath *up, float x1, float y1, float x2, float y2, float x3, float y3);
  66. void UPrcurveto(UserPath *up, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3);
  67. void UParc(UserPath *up, float x, float y, float r, float ang1, float ang2);
  68. void UParcn(UserPath *up, float x, float y, float r, float ang1, float ang2);
  69. void UParct(UserPath *up, float x1, float y1, float x2, float y2, float r);
  70. void closePath(UserPath *up);
  71.